package com.zdkj.subway.check.controller.stationTiecketManager.xianWngCJXXQR.shouRuJS;

import com.zdkj.subway.check.entity.SwPmLongPeriodSettlement;
import com.zdkj.subway.check.enums.ResultDetailMsg;
import com.zdkj.subway.check.mapper.SwPmLongPeriodSettlementMapper;
import com.zdkj.subway.check.result.Result;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 收入结算
 */
@RestController
@RequestMapping("/SRJS")
public class ShouRuJSController {
    @Resource
    SwPmLongPeriodSettlementMapper swPmLongPeriodSettlementMapper;

    /**
     * 长周期结算表
     * @param params
     * @return
     */
    @RequestMapping("/isLongPeriodSettlement")
    @ApiOperation(value = "长周期结算表", notes = "长周期结算表")
    public Result isLongPeriodSettlement(@RequestParam Map<String,String> params){
        Result res=new Result(ResultDetailMsg.OK);
        Map<String,Object> param=new HashMap<>();
        //获取线路站点
        String lineCode = params.get("lineCode");
        String stationCode = params.get("stationCode");
        if(StringUtils.isEmpty(lineCode) && StringUtils.isEmpty(stationCode)){
            res.setData(false);
        }
        if(StringUtils.isNotEmpty(params.get("lineCode"))){
            param.put("line_code",params.get("lineCode"));
        }
        if(StringUtils.isNotEmpty(params.get("stationCode"))){
            param.put("station_code",params.get("stationCode"));
        }
        param.put("DEL_FLAG","0");
        List<SwPmLongPeriodSettlement> swPmLongPeriodSettlements = swPmLongPeriodSettlementMapper.selectByMap(param);
        if(swPmLongPeriodSettlements==null || swPmLongPeriodSettlements.size()==0){
            res.setData(false);
        }else if(swPmLongPeriodSettlements.size()>0){
            res.setData(true);
        }
        return res;
    }
}
